package com.xmy.cultivate.schedule;

import com.xmy.cultivate.service.IRecordCourseService;
import com.xmy.cultivate.service.IStaffService;
import com.xmy.cultivate.util.SpringUtils;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.text.SimpleDateFormat;
import java.util.Date;

public class CommonJob implements Job {

    @Autowired
    IRecordCourseService iRecordCourseService = SpringUtils.getBean(IRecordCourseService.class);

    @Autowired
    IStaffService iStaffService = SpringUtils.getBean(IStaffService.class);

    private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    private void before() {
        System.out.println("公共任务：开始执行-" + dateFormat.format(new Date()));
    }

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        //试听超过7天未核对的删除
        iRecordCourseService.deleteTryListenRecordCourse(7);
        //学期班【假期被不算】超过时间未补课的，扣除金额，不能再按排补课
        iRecordCourseService.disposeTimeoutNotRepair();
        iStaffService.batchUpdateQyWeChartId();
    }

    private void after() {
        System.out.println("公共任务：执行结束");
        System.out.println();
    }
}
